package com.yb.web.global;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.yb.base.web.BaseAction;
import com.yb.bussiness.global.SystemLogService;
import com.yb.bussiness.global.SystemLogServiceImpl;
import com.yb.util.comm.Contants;
import com.yb.util.comm.RequestUtil;
import com.yb.util.framework.PageUtil;

/**
 * SuggestAction entity.
 * 
 * @author MyEclipse Persistence Tools
 */

public class SystemLogAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	
	private SystemLogService service;
	private List rows;
	private int total;
	
	public SystemLogAction() {
		service = new SystemLogServiceImpl();
	}

	/**
	 * 后台检索
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String search() {
		menuCls = RequestUtil.getParam(request, "menuCls", "");
		Map<String, String> map = new HashMap<String, String>();
		int page = RequestUtil.getParam(request, "page", 1);
		int row = RequestUtil.getParam(request, "rows", 10);
		String title = RequestUtil.getParam(request, "title", "");
		String startTime = RequestUtil.getParam(request, "startTime", "");
		String endTime = RequestUtil.getParam(request, "endTime", "");
		map.put("title", title);
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		PageUtil pu = service.getList(map, page, row);
		total = pu.getTotalRecords();
		rows = pu.getList();
		return Contants.JSONSTRING_RESULT_NAME;
	}
	/**
	 * 删除
	 * @return
	 */
	public String deleteSystemLog() {
		String idString = RequestUtil.getParam(request, "idString", "");

		boolean isFlag = false;
			isFlag = service.deleteByIdString(idString);
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = null;
		if (isFlag)
			message = "删除成功";
		else
			message = "删除失败";
		StringBuffer sb = new StringBuffer("[");
		sb.append("{\"message\":\"" + message + "\"" + "}");
		sb.append("]");

		try {
			out = response.getWriter();
			out.println(sb.toString());
		} catch (IOException e) {

			e.printStackTrace();
		}
		return null;
	}
	
	public List getRows() {
		return rows;
	}

	public void setRows(List rows) {
		this.rows = rows;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}
}